package com.tarena.lbs.user.service.impl;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.user.dao.repository.UserGroupRepository;
import com.tarena.lbs.user.pojo.param.UserGroupParam;
import com.tarena.lbs.user.pojo.query.UserGroupQuery;
import com.tarena.lbs.user.pojo.vo.UserGroupVO;
import com.tarena.lbs.user.service.UserGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class UserGroupServiceImpl implements UserGroupService {
    @Autowired
    private UserGroupRepository userGroupRepository;

    @Override
    public void save(UserGroupParam param) throws BusinessException {
        log.debug("保存人群数据,入参:{}",param);
            userGroupRepository.save(param);
        log.debug("保存人群数据成功,入参:{}",param);
    }

    @Override
    public PageResult<UserGroupVO> pageList(UserGroupQuery query) {
        log.debug("查询人群数据分页列表");
        PageResult<UserGroupVO> voPage = userGroupRepository.pageList(query);
        log.debug("查询人群数据分页列表成功，出参:{}",voPage.getObjects());
        return voPage;
    }

    @Override
    public UserGroupParam detail(UserGroupParam param) {
        log.debug("查询人群数据详情,入参:{}",param);
        UserGroupParam  userGroupParam = userGroupRepository.detail(param);
        log.debug("查询人群数据详情成功，出参:{}",userGroupParam);
        return userGroupParam;
    }

    @Override
    public void update(UserGroupParam param) {
        log.debug("更新人群数据,入参:{}",param);
        userGroupRepository.update(param);
        log.debug("更新人群数据成功,入参:{}",param);
    }

    @Override
    public void delete(UserGroupParam param) {
        log.debug("删除人群数据,入参:{}",param);
        userGroupRepository.delete(param);
        log.debug("删除人群数据成功,入参:{}",param);
    }
}
